package network;

import java.net.InetAddress;
import java.nio.ByteBuffer;

/**
 * represents a network event, created by the network manager upon receiving a packet
 * @author jack
 *
 */
public final class NetworkEvent
{
	private InetAddress address;
	private ByteBuffer packetData;
	
	/**
	 * creates a new network event
	 * @param address the address of the packet sender
	 * @param packetData the data contained within the packet
	 */
	public NetworkEvent(InetAddress address, ByteBuffer packetData)
	{
		this.address = address;
		this.packetData = packetData;
	}
	/**
	 * gets the data contained in the packet; the buffer returned should not be
	 * tampered with as it contains all the data from the packet (including the header
	 * information), instead the buffer methods should simply be utilized to read data
	 * directly, the position should already be correct
	 * @return returns the packet data
	 */
	public ByteBuffer getPacketData()
	{
		return packetData;
	}
	/**
	 * the address the packet was received from
	 * @return gets the packet sender address
	 */
	public InetAddress getInetAddress()
	{
		return address;
	}
}
